from django.db import models
from taskblock.models import TaskBlock


class Template(models.Model):
    """
    模板配置模板
    """
    name = models.CharField(max_length=100, verbose_name='模板名称')
    task_blocks_layout = models.JSONField(
        default=list,
        blank=True,
        verbose_name='任务块排列区配置',
        help_text='存储从taskblock表导入的任务块配置信息，包含任务名称、持续时间、颜色、所需设备等'
    )
    description = models.TextField(blank=True, null=True, verbose_name='模板描述')
    created_at = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')
    updated_at = models.DateTimeField(auto_now=True, verbose_name='更新时间')
    
    class Meta:
        verbose_name = '模板配置'
        verbose_name_plural = '模板配置'
        db_table = 'template'
        ordering = ['id']  # 按ID排序，保持模板序号顺序
    
    def __str__(self):
        return self.name
